const fs = require("fs");
const config = {
  inDir: "F:/测试/node.js 2.9——字符串处理 [2].html",
  outDir: "F:/测试",
};

let pattern1 = `<div style="--en-codeblock:true;--en-codeblockLanguage:`
let pattern2 = `;`
let pattern3 = `>`
let pattern4 = `</div>`

let str = fs.readFileSync(config.inDir,'utf-8')
let strs = str.split(pattern1)
let result = strs[0]
if(strs.length >1){
  for(let i=1;i<strs.length;i++){
    let postItem = strs[i]
    let index2 = postItem.indexOf(";")
    let language = postItem.substring(0,index2)
    if(language.indexOf("-")>=0){
      language = language.substring(language.indexOf("-")+1)
    }
    let connect = `<div class="code" language="${language}" style="--en-codeblock:true;--en-codeblockLanguage:`
    result+=connect;
    result+=postItem;
  }
}
console.log(result)



let index1 = str.indexOf(pattern1)
if(str.indexOf(pattern1)>=0){
  let pre = str.substring(0,index1)
  let index2 = str.substring(index1+pattern1.length,)
}
